package com.fufu.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fufu.pojo.FileCountNumber;
import com.fufu.service.FileCountNumberService;
import com.fufu.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/FileCountNumber")
public class FileCountNumberController {
  @Autowired
  private FileCountNumberService fileCountNumberService;

  /**
   * 统计目录下的word excel文件数量,并保存记录数据
   */
  @PostMapping("/fileCountNumbers")
  public Integer fileCountNumbers(String directoryPath){
    return fileCountNumberService.fileCountNumbers(directoryPath);
  }

  /**
   * 分页查询
   * @param pageNum
   * @param pageSize
   * @param model
   * @return
   */
  @GetMapping("/selectFileCountNumber")
  public Result selectFileCountNumber(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int pageSize, Model model) {
    Page<FileCountNumber> fileCountNumberPage = fileCountNumberService.selectFileCountNumber(pageNum, pageSize);
    return Result.success(fileCountNumberPage);
  }

  /**
   * 保存数据
   * @param fileCountNumber
   * @return
   */
  @PostMapping("/saveFileCountNumber")
public   Boolean saveFileCountNumber(FileCountNumber fileCountNumber){
    return fileCountNumberService.saveFileCountNumber(fileCountNumber);
  }

  /**
   * 修改数据
   * @param fileCountNumber
   * @return
   */
  @PostMapping("/updateFileCountNumber")
  public Boolean updateFileCountNumber(FileCountNumber fileCountNumber){
    return fileCountNumberService.updateFileCountNumber(fileCountNumber);
  }

  /**
   * 删除数据
   * @param id
   * @return
   */
  @GetMapping("/deleteFileCountNumber")
  public Boolean deleteFileCountNumber(Long id){
    return fileCountNumberService.deleteFileCountNumber(id);
  }

  /**
   * 根据id查询数据
   * @param id
   * @return
   */
  @GetMapping("/selectFileCountNumberById")
  public  FileCountNumber selectFileCountNumberById(Long id){
    return fileCountNumberService.selectFileCountNumberById(id);
  }
    
}
